﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BLL.Interface;
//using Model;
using DAL.Dao;
using DAL.Models;
//using System.Web.Script.Serialization;

namespace BLL
{
    public class BagInfoImpl:IBagInfoImpl
    {
        private readonly BagDaoimpl _dao;

        public int ExistNum { get { return _dao.ExistNum; } private set { } }
        public BagInfoImpl()
        {
            _dao = new BagDaoimpl();
        }
        public IList<Bag> GetBagInfo(int id)
        {
            var  rs = _dao.GetBagInfo(id);
            return rs;
        }
        public IList<Bag> GetList()
        {
            return _dao.GetList();
        }


        public (int, IList<Bag>) GetList( int rows, int page)
        {
            return _dao.GetList( rows, page);
        }

        public (int[],IList<Bag>[]) GetList(string name, string phone,int sernderRows,int senderPage,int getterRows,int getterPage)
        {
            return _dao.GetList(name, phone, sernderRows, senderPage, getterRows, getterPage);
        }

        public IList<Bag>[] GetList(string name,string phone)
        {
            return _dao.GetList(name,phone);
        }
        public (int,IList<Bag>) GetSenderList(string name, string phone,int rows,int page )
        {
            return _dao.GetSenderList(name, phone,rows,page);
        }
        public (int,IList<Bag>) GetGetterList(string name, string phone, int rows,int page)
        {
            return _dao.GetGetterList(name, phone,rows,page);
        }
        public Bag? GetItemByID(string id)
        {
            return _dao.GetItemByID(id);
        }
        public IList<Bag> GetList(string bagId,int page,int rows)
        {
            return _dao.GetList(bagId, page, rows);
        }

        public bool Add(Bag bag)
        {
            return  _dao.Add(bag);
        }
        public Bag Find(string  id)
        {
            return _dao.Find(id);
        }
        public Bag? Find(int id)
        {
            return _dao.Find(id);
        }
        public bool UpdateBag(string id,Bag newbag)
        {
            var rs = _dao.UpdateBagInfo(id, newbag,"all");
            return rs;
        }
        public bool DeliveryBag(string id, Bag newbag)
        {
            var rs = _dao.UpdateBagInfo(id, newbag,"delivery_begin");
            return rs;
        }

        public bool FinishDeliveryingBag(string id, Bag newbag)
        {
            var rs = _dao.UpdateBagInfo(id, newbag, "delivery_finish");
            return rs;
        }

        public bool DeleteBagInfo(string id)
        {
            return _dao.DeleteBagInfo(id);
        }


        public int GetGetterUserIDByBagID(string bagID)
        {
           return _dao.GetGetterUserIDByBagID(bagID);
        }
        public int GetSenderUserIDByBagID(string bagID)
        {
            return _dao.GetSenderUserIDByBagID (bagID); 
        }

    }
}
